Large amounts of data are frequently accessed and filtered to return the desired results. This process can impact performance at least insofar as memory requirements are concerned. For example, in database applications, frequently, a query may return a large number of rows (e.g., thousands, millions). Consequently, the database application must be prepared to handle this situation as efficiently as possible. If the application does not use memory conservatively, the application may run out of memory and shutdown abnormally.
Data retrieved from the database is usually displayed in a grid. The user is able to browse the rows in the grid by dragging a scrollbar and select specific rows in order to perform an operation supported by the application, such as deleting, moving, etc. Current grid implementations require memory in proportion to the number of rows in the grid in order to manage the selection. For example, the grid may have a flag per row to remember its selection state. This leads to excessive memory usage and performance issues when the selection needs to be quickly cleared. Moreover, some implementations require memory in proportion to the number of rows selected, thereby suffering from some of the same disadvantages.